const Mock = require('mockjs')

const listTemplate = {
  'items|15': [{
    id: '@increment',
    name: '@title(2, 5)',
    type: '@integer(1,3)',
    'status|1': ['pass', 'nonpass'],
    address: '@region',
    create_date: '@datetime',
    manager_id: '@integer(1, 100)'
  }]
}
const idTemplate = {
  id: 0,
  name: '@title(2, 5)',
  type: '@integer(1,3)',
  address: '@region',
  manager_id: '@integer(100)',
  file_id: '@id',
  create_date: '@datetime'
}

module.exports = [
  {
    url: '/enterprise/list*',
    type: 'get',
    response: config => {
      const items = Mock.mock(listTemplate).items
      return {
        code: 200,
        obj: {
          records: items
        }
      }
    }
  },
  {
    url: '/enterprise/[0-9]',
    type: 'get',
    response: config => {
      const item = Mock.mock(idTemplate)
      return {
        code: 200,
        data: item
      }
    }
  },
  {
    url: '/enterprise/update/[0-9]',
    type: 'post',
    response: config => {
      console.log(config)
      return {
        code: 200
      }
    }
  },
  {
    url: '/imageUpload',
    type: 'post',
    response: config => {
      return {
        code: 200
      }
    }
  },
  {
    url: '/enterprise/new',
    type: 'post',
    response: config => {
      return {
        code: 200
      }
    }
  },
  {
    url: '/enterprise/delete',
    type: 'post',
    response: config => {
      return {
        code: 200
      }
    }
  },
  {
    url: '/enterprise/setPass',
    type: 'post',
    response: config => {
      return {
        code: 200
      }
    }
  },
  {
    url: '/enterprise/setUnPass',
    type: 'post',
    response: config => {
      return {
        code: 200
      }
    }
  }
]
